require(['./config'],()=>{
    require(['swiper','template','header','footer'],(Swiper,template)=>{  //依赖于header模块 header模块又将header.HTML中的文件给加载出来
        class Index{
            constructor(){
                this.getBanner().then((resp)=>{
                    if(resp.code ==200){
                        var banners = resp.data.banners;
                        //调用template方法 需要先依赖它  
                        $('.swiper-wrapper').html(template('setbanner',{banners}));
                    }
                    this.banner()
                });
                this.list();
            }    
            //轮播图
            banner(){
                new Swiper('.main-banner',{
                    loop: true,
                    autoplay: {
                        delay:2000,
                        disableOnInteraction:false,
                    },
                    
                    pagination: {
                        el: '.swiper-pagination',
                        clickable :true,
                    },   
                }
                ) 
            }
            getBanner(){
                return new Promise((resolve,reject)=>{
                    $.get('http://www.xiongmaoyouxuan.com/api/tab/1',{start:1},resp=>{
                        resolve(resp)
                    })
                })   
            }
            list(){
                
                $.get('http://www.xiongmaoyouxuan.com/api/tab/1',{start:0},resp=>{
                    // console.log(resp)
                    var lis = resp.data;
                    
                    console.log(lis)
                    $('.main-center').html(template('center-con',{lis}));

                })
                
            }
        }
        
         new Index();
    })
})